﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Jewelnoid
{
    class Ball : Object2D
    {
        public Vector2 originalPosition;
        public Vector2 originalSpeed;
        public Vector2 speed;
        public int speedUnit;

        public Ball(Texture2D texture, Vector2 position, int speedUnit) :
            base(texture, position, Color.White)
        {
            this.originalPosition = position;
            this.speedUnit = speedUnit;

            this.speed = new Vector2(1, -10);
            this.speed.Normalize();
            this.speed *= this.speedUnit;

            this.originalSpeed = new Vector2(this.speed.X, this.speed.Y);
        }

        public void calculateSpeed(Vector2 distance)
        {
            distance.Normalize();

            this.speed.Y = this.speed.Y * (-1);

            this.speed.X = this.speed.X + (distance.X * 2);
        }

        public void setGenericDirection(int seed)
        {
            Random rand = new Random(seed);
            int randomNumber = rand.Next(-10, 10);

            this.speed = new Vector2(randomNumber, (-1)* randomNumber);
            
            this.speed.Normalize();
            this.speed *= this.speedUnit;
        }
    }
}
